import http from "@/config/config"


  const UserApi = {

    getUser:(page: Number,size: Number)=>{
        return http.post(`user/page/${page}/${size}`,
        {
          // "username":map.username,
          // "phone":map.phone,
          // "name":map.name,
          // "status":map.status,
          // "startTime":map.startTime,
          // "endTime":map.endTime
        }).then(res=>{
            return res.data;
        })
    },
    getUserByName:(page:Number,size:Number,name:String)=>{
      return http.post(`user/page/${page}/${size}`,
        {
          "name": name
        }).then(res=>{
           return res.data;
        })
    },
    addUser:(user:any)=>{
       return http.post('/user/add',{
          "username":user.username,
          "password":user.password,
          "phone":user.phone,
          "status":user.status,
          "name":user.name,
          "userImg":user.userImg
       }).then(res=>{
          return res.data
       })
    },
    changeStatus:(id:Number,status:Number)=>{
      return http.put(`/user/status/${id}/${status}`).then(res=>{
        return res.data
      })
    },
    //修改用户信息
    updateUser:(user:any)=>{
      return http.put('/user/update',{
         "id":user.id,
         "username":user.username,
         "password":user.password,
         "phone":user.phone,
         "status":user.status,
         "name":user.name,
         "userImg":user.userImg
      }).then(res=>{
         return res.data
      })
   },
   //根据id删除用户，接受的是一个数组
   deleteUser:(ids:any)=>{
       return http.post('/user/delete',{
         "ids":ids
       }).then(res=>{
         return res.data
       })
   }

  }


export default UserApi;





  
  

 
